<qscms:load type="category"/>
<div class="modal_fast_creat J_modal_fast_creat">
    <a class="a_close" href="javascript:;"></a>
    <div class="creat_content">
        <div class="step_box">
            <h3>没简历怎么投职位？花30秒轻松填写简历搞定工作</h3>
            <div class="creat_title_box"><span>已有简历，请直接</span><span><a class="btn01 btn_green qulogin toSwitchModal" data-index="1" href="javascript:;">立即登录</a></span></div>
        </div>
        <div class="creat_main">
            <div class="lis">
                <span class="mr18"><input type="text" name="fullname" id="fullname" placeholder="姓名" class="common width177 name"></span>
                <span class="mr18">
                    <div class="common share_ddl width177 J_dropdown J_listitme_parent">
                        <span class="J_listitme_text">期望薪资</span><em></em>
                        <div class="dropdowbox7 J_dropdown_menu">
                            <div class="dropdow_inner7 width197">
                                <ul class="nav_box">
                                    <qscms:classify 列表名="wage_list" 类型="QS_wage" 显示数目="100"/>
                                    <volist name="wage_list" id="wage">
                                        <li><a class="J_listitme" href="javascript:;" data-code="{$key}">{$wage}</a></li>
                                    </volist>
                                </ul>
                            </div>
                        </div>
                        <input class="J_listitme_code" name="wage" id="wage" type="hidden" value=""/>
                    </div>
                </span>
                <span>
                    <div class="sex_radio_list J_radioitme_parent">
                        <div class="n <if condition="$jobs['sex'] eq 1 or $jobs['sex'] eq 0">checked</if> J_radioitme" data-code="1">男</div>
                        <div class="w <if condition="$jobs['sex'] eq 2">checked</if> J_radioitme" data-code="2">女</div>
                        <div class="clear"></div>
                        <input class="J_radioitme_code" name="sex" id="sex" type="hidden" value="{$jobs.sex|default='1'}" />
                      </div>
                </span>
                <div class="clear"></div>
            </div>
            <div class="lis">
                <span class="mr18">
                    <div class="common share_ddl width177 J_dropdown J_listitme_parent">
                        <span class="J_listitme_text"><if condition="$jobs['birthdate']">{$jobs['birthdate']}<else/>出生年份</if></span><em></em>
                        <div class="dropdowbox6 J_dropdown_menu">
                            <div class="dropdow_inner6">
                                <ul class="nav_box J_birthdy">
                                    <div class="J_birthday_box active"></div>
                                    <div class="J_birthday_box"></div>
                                    <div class="J_birthday_box"></div>
                                </ul>
                                <a href="javascript:;" class="prev J_birthday_prev"></a>
                                <a href="javascript:;" class="next J_birthday_next"></a>
                            </div>
                        </div>
                        <input class="J_listitme_code" name="birthdate" id="birthdate" type="hidden" value="<if condition="$jobs['birthdate']">{$jobs['birthdate']}</if>" />
                    </div>
                </span>
                <span class="mr18">
                    <div class="common share_ddl width177 J_dropdown J_listitme_parent">
                        <span class="J_listitme_text"><if condition="$jobs['experience'] eq 0">工作经验<else/>{$jobs['experience_cn']}</if></span><em></em>
                        <div class="dropdowbox7 J_dropdown_menu">
                            <div class="dropdow_inner7 width197">
                                <ul class="nav_box">
                                    <qscms:classify 列表名="experience_list" 类型="QS_experience" 显示数目="100"/>
                                    <volist name="experience_list" id="experience">
                                        <li><a class="J_listitme" href="javascript:;" data-code="{$key}">{$experience}</a></li>
                                    </volist>
                                </ul>
                            </div>
                        </div>
                        <input class="J_listitme_code" name="experience" id="experience" type="hidden" value="<if condition="$jobs['experience'] neq 0">{$jobs['experience']}</if>" />
                    </div>
                </span>
                <span>
                    <div class="common share_ddl width177 J_dropdown J_listitme_parent">
                        <span class="J_listitme_text"><if condition="$jobs['education'] eq 0">最高学历<else/>{$jobs['education_cn']}</if></span><em></em>
                        <div class="dropdowbox5 J_dropdown_menu">
                            <div class="dropdow_inner5 width197">
                                <ul class="nav_box">
                                    <qscms:classify 列表名="education_list" 类型="QS_education" 显示数目="100"/>
                                    <volist name="education_list" id="education">
                                        <li><a class="J_listitme" href="javascript:;" data-code="{$key}">{$education}</a></li>
                                    </volist>
                                </ul>
                            </div>
                        </div>
                        <input class="J_listitme_code" name="education" id="education" type="hidden" value="<if condition="$jobs['education'] neq 0">{$jobs['education']}</if>" />
                    </div>
                </span>
                <div class="clear"></div>
            </div>
            <div class="lis">
                <span><input type="text" name="telephone" id="telephone" placeholder="手机号" class="common width234"></span>
                <span class="mr18"><input type="button" id="getVerfyCodeRes" value="获取验证码" class="btn_verficode"></span>
                <span><input type="text" name="mobile_vcode" id="mobile_vcode" placeholder="手机验证码" class="common width177"></span>
                <div class="clear"></div>
            </div>
            <div class="lis pl16 btns">
                <input class="J_resultcode_jobs" name="intention_jobs_id" id="intention_jobs_id" type="hidden" value="{$jobs.topclass}.{$jobs.category}.{$jobs.subclass}"/>
                <input class="J_resultcode_city" name="district" id="district" type="hidden" value="{$jobs.district}.{$jobs.sdistrict}.{$jobs.tdistrict}"/>
                <input type="hidden" name="jid" value="{$jid}">
                <a class=" btn02 btn_blue reg1" id="btnCreatResume" href="javascript:;">立即注册</a>
            </div>
        </div>
    </div>
</div>
<div class="modal_fast_creat" style="display:none">
    <a class="a_close" href="javascript:;"></a>
    <div class="creat_content">
        <div class="step_box">
            <h3>账号登录</h3>
            <div class="creat_title_box"><span>没有简历，请直接</span><span><a class="btn01 btn_green qulogin toSwitchModal" data-index="0" href="javascript:;">立即注册</a></span></div>
        </div>
        <div class="modal_login_group">
            <div class="modal_login_left"></div>
            <div class="modal_login_right">
                <div class="right_all_box">
                    <if condition="C('qscms_weixin_apiopen') and C('qscms_weixin_scan_login')">
                        <div class="code_login" title="切换扫码登录"></div>
                        <div class="txt_login"  title="切换到用户名密码登录"></div>
                    </if>
                    <div class="tit">
                        <div class="switch_login_type">
                            <div class="J_switch_type login_type select">账号登录<div class="bottom_line"></div></div>
                            <if condition="C('qscms_sms_open') eq 1"><div class="J_switch_type login_type">手机动态码登录<div class="bottom_line"></div></div>
                            <div class="clear"></div></if>
                        </div>
                    </div>
                    <div class="login_type_group">
                        <div class="type_box">
                            <div class="err J_errbox"></div>
                            <div class="inputbox J_focus">
                                <div class="imgbg"></div>
                                <input type="text" class="input_login" name="username" id="username" placeholder="手机号/会员名/邮箱"/>
                            </div>
                            <div class="inputbox J_focus">
                                <div class="imgbg pwd"></div>
                                <input type="password" class="input_login pwd J_loginword" name="password" id="password" placeholder="请输入密码"  />
                            </div>
                            <div class="btnbox">
                                <input class="btn_login J_hoverbut" type="button" id="J_dologinByAccount" value="登录" />
                            </div>
                            <div class="qqbox">
                                <span class="txt first">
                                    <notempty name="oauth_list">
                                        <if condition="!(count($oauth_list) eq 1 AND array_key_exists('weixin',$oauth_list))">
                                            合作账号登录
                                        </if>
                                    </notempty>
                                </span>
                                <div class="appsparent">
                                    <div class="apps">
                                        <volist name="oauth_list" id="oauth">
                                            <if condition="$key neq 'weixin'">
                                                <a class="ali {$key}" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}" title="{$oauth.name}账号登录"></a>
                                            </if>
                                        </volist>
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </div>
                        <div class="type_box">
                            <div class="err J_errbox"></div>
                            <div class="inputbox J_focus">
                                <div class="imgbg"></div>
                                <input type="text" class="input_login" name="mobile" id="mobile" placeholder="请输入手机号"/>
                            </div>
                            <div class="inputbox J_focus">
                                <div class="imgbg pwd"></div>
                                <input type="text" class="input_login pwd code J_loginword" name="verfy_code" id="verfy_code" placeholder="请输入手机验证码"  />
                                <input class="btn_login J_hoverbut get_code" type="button" id="getVerfyCode" value="获取验证码" />
                            </div>
                            <div class="btnbox">
                                <input class="btn_login J_hoverbut" type="button" id="J_dologinByMobile" value="登录" />
                            </div>
                            <div class="qqbox">
                                <span class="txt first">
                                    <notempty name="oauth_list">
                                        <if condition="!(count($oauth_list) eq 1 AND array_key_exists('weixin',$oauth_list))">
                                            合作账号登录
                                        </if>
                                    </notempty>
                                </span>
                                <div class="appsparent">
                                    <div class="apps">
                                        <volist name="oauth_list" id="oauth">
                                            <if condition="$key neq 'weixin'">
                                                <a class="ali {$key}" href="{:U('callback/index',array('mod'=>$key,'type'=>'login'))}" title="{$oauth.name}账号登录"></a>
                                            </if>
                                        </volist>
                                    </div>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </div>
                        <div class="clear"></div>
                    </div>
                    <if condition="C('qscms_weixin_apiopen') and C('qscms_weixin_scan_login')">
                        <div class="J_qr_code_show" style="display: none">
                            <div id="J_weixinQrCode" class="codebox"></div>
                            <div class="codetip">请使用微信扫一扫登录</div>
                        </div>
                        <script type="text/javascript">
                            var qrcode_time,
                                waiting_weixin_scan = function(){
                                    $.getJSON(qscms.root + '?m=Home&c=Members&a=waiting_weixin_login',function(result){
                                        if(result.status == 1){
                                            window.location.href = result.data;
                                        }
                                    });
                                },
                                get_weixin_qrcode = function(){
                                    clearInterval(qrcode_time);
                                    $.getJSON(qscms.root + '?m=Home&c=Qrcode&a=get_weixin_qrcode',{type:'login'},function(result){
                                        if(result.status == 1){
                                            $('#J_weixinQrCode').empty().append(result.data);
                                            qrcode_time=setInterval(waiting_weixin_scan,5000);
                                        }else{
                                            $('#J_weixinQrCode').empty().html(result.msg);
                                        }
                                    });
                                };
                            get_weixin_qrcode();
                        </script>
                    </if>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<div id="popup-captcha"></div>
<input type="hidden" id="btnCheck" />
<div id="popup-captcha-login"></div>
<input type="hidden" id="btnCheckLogin" />
<input type="hidden" id="verify_userlogin" value="{$verify_userlogin}">
<input type="hidden" id="J_loginType" value="0">
<input type="hidden" id="J_sendVerifyType" value="0">
<input type="hidden" id="J_sms_open" value="{:C('qscms_sms_open')}">
<script type="text/javascript" src="../public/js/jquery.listitem.js"></script>
<script type="text/javascript" src="../public/js/jquery.dropdown.js"></script>
<script type="text/javascript" src="../public/js/jquery.modal.fastresume.js"></script>
<script type="text/javascript">
    // 顶部二维码登录切换
    $(".code_login,.txt_login").click( function () {
        $(".login_type_group").toggle();
        $(".J_qr_code_show").toggle();
        $(".code_login").toggle();
        $(".txt_login").toggle();
        $('.right_all_box .tit').toggle();
    });

    // 关闭窗口
    $('.a_close').die().live('click', function(event) {
        $('.modal').remove();
        $('.modal_backdrop').remove();
    });

    // 登录和注册窗口切换
    $('.toSwitchModal').die().live('click', function(event) {
        var thisInex = $(this).data('index');
        $('.modal_fast_creat').eq(thisInex).show().siblings('.modal_fast_creat').hide();
    });

    // 快速注册发送短信验证码
    var regularMobile = /^13[0-9]{9}$|14[0-9]{9}$|15[0-9]{9}$|18[0-9]{9}$|17[0-9]{9}$/; // 验证手机号正则
    $('input[name="telephone"]').keyup(function(event) {
        var telephoneValue = $(this).val();
        if (telephoneValue.length >= 11) {
            if (telephoneValue != "" && !regularMobile.test(telephoneValue)) {
               $('input[name="telephone"]').addClass('error_creat').focus();
                return false;
            }
        }
    });

    $.ajax({
        // 获取id，challenge，success（是否启用failback）
        url: "{:U('/captcha')}?t=" + (new Date()).getTime(), // 加随机数防止缓存
        type: "get",
        dataType: "json",
        success: function (data) {
            // 使用initGeetest接口
            // 参数1：配置参数
            // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
            initGeetest({
                gt: data.gt,
                challenge: data.challenge,
                product: "popup", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
            }, handlerRes);
        }
    });
    var handlerRes = function(captchaObj) {
        captchaObj.appendTo("#popup-captcha");
        captchaObj.bindOn("#btnCheck");
        captchaObj.onSuccess(function() {
            toSetSms();
        });
        captchaObj.onFail(function() {
            
        });
        captchaObj.onError(function() {
            
        });
        captchaObj.getValidate()
    };

    // 点击获取验证码
    $('#getVerfyCodeRes').die().live('click', function() {
        var telephoneValue = $('input[name="telephone"]').val();
        if (!telephoneValue.length) {
            $('input[name="telephone"]').addClass('error_creat').focus();
            return false;
        }
        if (telephoneValue != "" && !regularMobile.test(telephoneValue)) {
           $('input[name="telephone"]').addClass('error_creat').focus();
            return false;
        }
        $.ajax({
            url: "{:U('members/ajax_check')}",
            cache: false,
            async: false,
            type: 'post',
            dataType: 'json',
            data: { type: 'mobile', param: telephoneValue },
            success: function(result) {
                if (result.status) {
                    $('input[name="telephone"]').removeClass('error_creat');
                    <if condition="C('qscms_captcha_open') eq 1 && C('qscms_captcha_config.varify_mobile') eq 1">
                        $("#btnCheck").click();
                    <else/>
                        toSetSms();
                    </if>
                } else {
                    disapperTooltip("remind", "手机号已被注册");
                }
            }
        });
    });
    
    // 发送验证码
    function toSetSms() {
        $.ajax({
            url: "{:U('members/reg_send_sms')}",
            type: 'POST',
            dataType: 'json',
            data: {mobile: $.trim($('input[name="telephone"]').val()),'sms_type':'gsou_reg',geetest_challenge: $("input[name='geetest_challenge']").val(),geetest_validate: $("input[name='geetest_validate']").val(),geetest_seccode: $("input[name='geetest_seccode']").val()}
        })
        .done(function(data) {
            if (parseInt(data.status)) {
                setTimeout(function() { 
                    disapperTooltip("success", "验证码已发送，请注意查收");
                },800)
                
                // 开始倒计时
                var countdown = 180;
                function settime() {
                    if (countdown == 0) {
                        $('#getVerfyCodeRes').prop("disabled", 0);
                        $('#getVerfyCodeRes').removeClass('disabled');
                        $('#getVerfyCodeRes').val('获取验证码');
                        countdown = 180;
                        return;
                    } else {
                        $('#getVerfyCodeRes').prop("disabled", !0);
                        $('#getVerfyCodeRes').addClass('disabled');
                        $('#getVerfyCodeRes').val('重新发送' + countdown + '秒');
                        countdown--;
                    }
                    setTimeout(function() { 
                        settime()
                    },1000)
                }
                settime();
            } else {
                setTimeout(function() { 
                    disapperTooltip("remind", data.msg);
                },1500)
            }
        });
    }

    // 创建简历验证
    $('#btnCreatResume').die().live('click', function() {
        var fullnameValue = $.trim($('input[name="fullname"]').val());
        var sexValue = $.trim($('input[name="sex"]').val());
        var birthdateValue = $.trim($('input[name="birthdate"]').val());
        var educationValue = $.trim($('#education').val());
        var experienceValue = $.trim($('#experience').val());
        var residenceValue = $.trim($('input[name="residence"]').val());
        var intentionJobsValue = $.trim($('#intention_jobs_id').val());
        var districtValue = $.trim($('#district').val());
        var wageValue = $.trim($('#wage').val());
        var telephoneValue = $.trim($('input[name="telephone"]').val());
        var mobile_vcodeValue = $.trim($('input[name="mobile_vcode"]').val());
        var jid = $.trim($('input[name="jid"]').val());
        $('.modal_fast_creat .error_creat').each(function() {
            $(this).removeClass('error_creat');
        });
        if(jid == ""){
            disapperTooltip("remind", "请选择要申请的职位");
            return false;
        }
        if (intentionJobsValue == "") {
            $('.J_creat_category').addClass('error_creat');
            return false;
        }
        if (wageValue == "") {
            $('input[name="wage"]').closest('.share_ddl').addClass('error_creat');
            return false;
        }
        if (districtValue == "") {
            $('.J_creat_address').addClass('error_creat');
            return false;
        }
        if (experienceValue == "") {
            $('input[name="experience"]').closest('.share_ddl').addClass('error_creat');
            return false;
        }
        if (educationValue == "") {
            $('input[name="education"]').closest('.share_ddl').addClass('error_creat');
            return false;
        }
        if (birthdateValue == "") {
            $('input[name="birthdate"]').closest('.share_ddl').addClass('error_creat');
            return false;
        }
        if (fullnameValue == "") {
            $('input[name="fullname"]').addClass('error_creat').focus();
            return false;
        }
        if (fullnameValue != "" && fullnameValue.length > 10) {
            $('input[name="fullname"]').addClass('error_creat').focus();
            return false;
        }
        if (sexValue == "") {
            disapperTooltip("remind", "请选择性别");
            return false;
        }
        if (telephoneValue == "") {
            $('input[name="telephone"]').addClass('error_creat').focus();
            return false;
        }
        if (telephoneValue != "" && !regularMobile.test(telephoneValue)) {
            $('input[name="telephone"]').addClass('error_creat').focus();
            return false;
        }
        if (mobile_vcodeValue == "") {
            $('input[name="mobile_vcode"]').addClass('error_creat').focus();
            return false;
        }
        // 提交表单
        $.ajax({
            url: "{:U('AjaxPersonal/resume_add')}",
            type: 'POST',
            dataType: 'json',
            data: {fullname: fullnameValue, sex: sexValue, birthdate: birthdateValue, education: educationValue, experience: experienceValue, telephone: telephoneValue, intention_jobs_id: intentionJobsValue, district: districtValue, wage: wageValue, mobilevcode: mobile_vcodeValue,jid:jid}
        })
        .done(function(data) {
            if (parseInt(data.status)) {
                if(data.data.html){
                    $('.modal').remove();
                    $('.modal_backdrop').remove();
                    var qsDialogSons = $(this).dialog({
                        title: '申请职位',
                        loading: true
                    });
                    qsDialogSons.setContent(data.data.html);
                }else{
                    disapperTooltip("remind", data.msg);
                }
            } else {
                disapperTooltip("remind", data.msg);
            }
        })
        .fail(function(result) {
           disapperTooltip("remind", result.msg);
        });
    });

    // 登录窗口登录方式切换
    var F = -1;
    $('.J_switch_type').click(function() {
        $(this).addClass('select').siblings().removeClass('select');
        var switchIndex = $('.J_switch_type').index(this);
        $('#J_loginType').val(switchIndex);
        $('.login_type_group').stop(true).animate({
            left: 330 * F * switchIndex + "px"
        }, 200);
    });

    // 回车登录
    $('.J_loginword').bind('keypress', function(event) {
        if (event.keyCode == "13") {
            $(this).closest('.type_box').find('.btnbox .btn_login').click();
        }
    });

    // 账号登录验证
    $('#J_dologinByAccount').die().live('click', function() {
        var usernameValue = $.trim($('#username').val());
        var passwordValue = $.trim($('#password').val());
        var $errbox = $(this).closest('.type_box').find('.J_errbox');
        if (usernameValue == "") {
            $errbox.text('请填写手机号/会员名/邮箱').show();
            $('#username').focus();
            return false;
        }
        if (passwordValue == "") {
            $errbox.text('请填写密码').show();
            $('#password').focus();
            return false;
        }
        $errbox.text('').hide();console.log($("#verify_userlogin").val());
        if(eval($("#verify_userlogin").val())==1){
            $('#J_sendVerifyType').val('0');
            $("#btnCheckLogin").click();
        }else{
            $('#J_dologinByAccount').val('登录中...').addClass('btn_disabled').prop('disabled', !0);
            doLogin();
        }
    });

    // 手机动态码登录输入手机号时
    $('input[name="mobile"]').keyup(function(event) {
        var $errbox = $(this).closest('.type_box').find('.J_errbox');
        var mobileValue = $(this).val();
        if (mobileValue.length >= 11) {
            if (mobileValue != "" && !regularMobile.test(mobileValue)) {
                $errbox.text('手机号码格式不正确').show();
                return false;
            }
        }
    });

    // 手机动态码登录时获取手机验证码
    $('#getVerfyCode').die().live('click', function(event) {
        var mobileValue = $('input[name="mobile"]').val();
        var $errbox = $(this).closest('.type_box').find('.J_errbox');
        if (!mobileValue.length) {
            $errbox.text('请输入手机号码').show();
            $('input[name="mobile"]').focus();
            return false;
        }
        if (mobileValue != "" && !regularMobile.test(mobileValue)) {
            $errbox.text('手机号码格式不正确').show();
            $('input[name="mobile"]').focus();
            return false;
        }
        $.ajax({
            url: "{:U('members/ajax_check')}",
            cache: false,
            async: false,
            type: 'post',
            dataType: 'json',
            data: { type: 'mobile', param: mobileValue },
            success: function(result) {
                if (!result.status) {
                    $errbox.text('').hide();
                    $('#J_sendVerifyType').val('1');
                    $("#btnCheckLogin").click();
                } else {
                    $errbox.text('账号不存在！').show();
                    return false;
                }
            }
        });
    });

    // 手机动态码登录验证
    $('#J_dologinByMobile').die().live('click', function() {
        var mobileValue = $.trim($('#mobile').val());
        var verfyCodeValue = $.trim($('#verfy_code').val());
        var $errbox = $(this).closest('.type_box').find('.J_errbox');
        if (mobileValue == "") {
            $errbox.text('请填写手机号').show();
            $('#mobile').focus();
            return false;
        }
        if (mobileValue != "" && !regularMobile.test(mobileValue)) {
            $errbox.text('手机号码格式不正确').show();
            return false;
        }
        if (verfyCodeValue == "") {
            $errbox.text('请填写手机验证码').show();
            $('#verfy_code').focus();
            return false;
        }
        $errbox.text('').hide();
        if(eval($("#verify_userlogin").val())==1){
            $('#J_sendVerifyType').val('0');
            $("#btnCheckLogin").click();
        }else{
            $('#J_dologinByMobile').val('登录中...').addClass('btn_disabled').prop('disabled', !0);
            doLogin();
        }
    });

    // 登录方法
    function doLogin() {
        var loginTypeValue = eval($('#J_loginType').val());
        $('.type_box').eq(loginTypeValue).find('.btnbox .btn_login').val('正在登录中...');
        if (loginTypeValue) {
            var mobileValue = $.trim($('input[name=mobile]').val());
            var verfyCodeValue = $.trim($('input[name=verfy_code]').val());
            var $errbox = $('#J_dologinByMobile').closest('.type_box').find('.J_errbox');
            // 提交表单
            $.ajax({
                url: "{:U('members/login')}",
                type: "post",
                dataType: "json",
                data: {
                    mobile: mobileValue,
                    mobile_vcode: verfyCodeValue,
                    // 二次验证所需的三个值
                    geetest_challenge: $("input[name='geetest_challenge']").val(),
                    geetest_validate: $("input[name='geetest_validate']").val(),
                    geetest_seccode: $("input[name='geetest_seccode']").val()
                },
                success: function (result) {
                    if (parseInt(result.status)) {
                       window.location.reload();
                    } else {
                        $errbox.text(result.msg).show();
                        $('#J_dologinByMobile').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                        $("#verify_userlogin").val(result.data);
                    }
                }
            });
        } else {
            var usernameValue = $.trim($('input[name=username]').val());
            var passwordValue = $.trim($('input[name=password]').val());
            var $errbox = $('#J_dologinByAccount').closest('.type_box').find('.J_errbox');
            // 提交表单
            $.ajax({
                url: "{:U('members/login')}",
                type: "post",
                dataType: "json",
                data: {
                    username: usernameValue,
                    password: passwordValue,
                    // 二次验证所需的三个值
                    geetest_challenge: $("input[name='geetest_challenge']").val(),
                    geetest_validate: $("input[name='geetest_validate']").val(),
                    geetest_seccode: $("input[name='geetest_seccode']").val()
                },
                success: function (result) {
                    if (parseInt(result.status)) {
                        window.location.reload();
                    } else {
                        $errbox.text(result.msg).show();
                        $('#J_dologinByAccount').val('登录').removeClass('btn_disabled').prop('disabled', 0);
                        $("#verify_userlogin").val(result.data);
                    }
                }
            });
        }
    }

    // 极验通过之后需要做的操作
    function validDoSomethig() {
        var toType = eval($('#J_sendVerifyType').val());
        var loginTypeValue = eval($('#J_loginType').val());
        if (toType) {
            var mobileValue = $('input[name="mobile"]').val();
            $.ajax({
                url: "{:U('members/reg_send_sms')}",
                cache: false,
                async: false,
                type: 'post',
                dataType: 'json',
                data: { sms_type: 'login', mobile: mobileValue,geetest_challenge: $("input[name='geetest_challenge']").val(),geetest_validate: $("input[name='geetest_validate']").val(),geetest_seccode: $("input[name='geetest_seccode']").val()},
                success: function(result) {
                    if (result.status) {
                        disapperTooltip("success", "验证码已发送，请注意查收");
                        // 开始倒计时
                        var countdown = 180;
                        function settime() {
                            if (countdown == 0) {
                                $('#getVerfyCode').prop("disabled", 0);
                                $('#getVerfyCode').removeClass('btn_disabled');
                                $('#getVerfyCode').val('获取验证码');
                                countdown = 180;
                                return;
                            } else {
                                $('#getVerfyCode').prop("disabled", !0);
                                $('#getVerfyCode').addClass('btn_disabled');
                                $('#getVerfyCode').val('重新发送' + countdown + '秒');
                                countdown--;
                            }
                            setTimeout(function() { 
                                settime()
                            },1000)
                        }
                        settime();
                    } else {
                        $('.type_box').eq(loginTypeValue).addClass('err');
                        $('.type_box').eq(loginTypeValue).find('.J_errbox').text(result.msg);
                        return false;
                    }
                }
            });
        } else {
            doLogin();
        }
    }

    // 登录配置验证码
    $.ajax({
        // 获取id，challenge，success（是否启用failback）
        url: qscms.root+'?m=Home&c=captcha&t=' + (new Date()).getTime(), // 加随机数防止缓存
        type: "get",
        dataType: "json",
        success: function (data) {
            // 使用initGeetest接口
            // 参数1：配置参数
            // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
            initGeetest({
                gt: data.gt,
                challenge: data.challenge,
                product: "popup", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
            }, handler);
        },
        error:function(data){
            alert(data['responseText']);
        }
    });
    // 验证码加载
    var handler = function(captchaObj) {
        captchaObj.appendTo("#popup-captcha-login");
        captchaObj.bindOn("#btnCheckLogin");
        captchaObj.onSuccess(function() {
            validDoSomethig();
        });
        captchaObj.onFail(function() {
            var loginTypeValue = eval($('#J_loginType').val());
            $('.type_box').eq(loginTypeValue).find('.J_errbox').text('滑动验证失败！').show();
        });
        captchaObj.onError(function() {
            var loginTypeValue = eval($('#J_loginType').val());
            $('.type_box').eq(loginTypeValue).find('.J_errbox').text('网络错误，请稍候再试！').show();
        });
        captchaObj.getValidate()
    };
</script>